<?php

namespace App\Console\Commands;

use GuzzleHttp\Client;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\Request;

class test extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'command:test';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Execute the console command.
     *
     * @return int
     */
    public function handle()
    {
        $command = "git pull"; //ls是linux下的查目录，文件的命令
        exec($command,$array); //执行命令
        var_dump($array);

        return ;
        $CORP_ID="ww1e76bb08a03c9d20";
        $CONTACT_SYNC_SECRET="tkG5XpCINuJ2XRVAFPJ4Rp0lbbEQYAfPlcEZSoUXIPY";

         $client=new Client(['base_uri' => 'https://qyapi.weixin.qq.com/cgi-bin','verify'=>false]);
         $data=$client->get(sprintf("/cgi-bin/gettoken?corpid=%s&corpsecret=%s",$CORP_ID,$CONTACT_SYNC_SECRET));
         $res=$this->build($data->getBody()->getContents());
         if($res['errmsg']!="ok"){
             return  $res['errmsg'];
         }

        $access_token=$res['access_token'];
         var_dump($access_token);
        $data=$client->post(sprintf("/cgi-bin/message/send?access_token=%s",$access_token),[
            "touser"=>"@all",
//           "toparty"=>"PartyID1|PartyID2",
//           "totag" =>"TagID1 | TagID2",
           "msgtype" =>"text",
           "agentid" => 1,
           "text" => [
                "content" => "你的快递已到，请携带工卡前往邮件中心领取。\n出发前可查看<a href=\"http://work.weixin.qq.com\">邮件中心视频实况</a>，聪明避开排队。"
           ],
//           "safe"=>0,
//           "enable_id_trans"=> 0,
//           "enable_duplicate_check"=> 0,
//           "duplicate_check_interval"=> 1800
        ]);
        $res=$this->build($data->getBody()->getContents());
        var_dump($res);
        return 0;
    }

    public function build($content){
       return json_decode($content,true);

    }
}
